﻿using ConfExpert.Forms.Base;
using DevTeam;
using System;
using System.Drawing;

namespace ConfExpert.Forms.Depo
{
    public partial class OrtakKumasCikislari : XForm
    {
        public OrtakKumasCikislari()
        {
            InitializeComponent();
        }

        private void OrtakKumasCikislari_Load(object sender, EventArgs e)
        {


            gvOrtakKumas.Init("GetDosyaBazliOrtakKumaslar", WhoAmI);
            gvOrtakKumas.AddDetailGrid(gvArtikel, "CikisEmriId,DosyaNo,ProductId");

            gvOrtakKumas.SetCaptions("AtelyeId:Atölye", "Qty: CikilanMetraj", "CikisEmriId:Çıkış Emri", "stGenelId:ÇıkışEmriDurumu");
            gvOrtakKumas.AddSummary("Qty", "Adet");
            gvOrtakKumas.FormatAsNumber(1, "Ihtiyac", "Qty");

            gvArtikel.MakeColumnInvisible("OrtakKumasLinesId", "CikisEmriId", "DosyaNo");
            gvArtikel.AddSummary("Ihtiyac", "CikilacakMetraj", "Adet");
            gvArtikel.SetCaptions("CikilacakMetraj:CikilanMetraj");

            gvOrtakKumas.BestFitColumns();
            gvArtikel.BestFitColumns();

            gvOrtakKumas.Columns["OrtakKumasNotu"].Width = 100;

            gvOrtakKumas.RowCellStyle += gvOrtakKumas_RowCellStyle;
            gvArtikel.RowCellStyle += gvArtikel_RowCellStyle;
        }

        void gvArtikel_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
        {
            if (e.RowHandle > -1)
            {
                switch (e.Column.FieldName)
                {
                    case "CikilacakMetraj":
                        e.Appearance.Font = new Font(DevExpress.Utils.AppearanceObject.DefaultFont, FontStyle.Bold);
                        break;
                }
            }
        }

        void gvOrtakKumas_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
        {
            if (e.RowHandle > -1)
            {
                switch (e.Column.FieldName)
                {
                    case "Qty":
                    case "DosyaNo":
                        e.Appearance.Font = new Font(DevExpress.Utils.AppearanceObject.DefaultFont, FontStyle.Bold);
                        break;
                }
            }
        }

        private void bbiRefresh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gvOrtakKumas.RefreshDataSource("GetDosyaBazliOrtakKumaslar", WhoAmI);
        }
    }
}
